<?php

namespace App\Http\Controllers\Course;

use App\Http\Controllers\BaseController;
use App\Models\CourseAfterSaleMessage;
use Illuminate\Http\Request;

class AfterSaleMessage extends BaseController
{
    public function store(Request $request)
    {
        $params = $this->validate($request,[
            'course_order_id' => 'required|integer',
            'content' => 'required|max:500',
        ]);

        $params['user_id'] = auth('api')->id();
        $msg = CourseAfterSaleMessage::query()->create($params);

        if ($msg->getKey()){
            return $this->success('留言成功');
        }

        return $this->error('留言失败');
    }
}
